import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Link ,browserHistory} from 'react-router';
import api from '../api';
import {message,Row,Col,Card,Input,Button} from 'antd';
import NavBar from '../common/NavBar';
import ContentBody from '../common/ContentBody';

export default class WithdrawDetail extends React.Component {
  constructor(props, context){
      super(props, context);
      let {id} = this.props.location.query||{};
      this.state={
          id,
          withdraw:{},
          user:{}
      };
  }

  componentWillMount(){
      let {id} = this.state;
      if(id){
        this.doGet(id)
      }
  }

  componentDidUpdate() {
    
  }
  async doGet(id){
    let {withdrawInfo,userInfo} = await api('/user/withdraw/detail',{id});
    if(withdrawInfo.cd!=0){
        message.error(withdrawInfo.msg);
    }
    if(userInfo.cd!=0){
         message.error(userInfo.msg);
    }
    this.setState({
        withdraw:withdrawInfo.data,
        user:userInfo.data
    })
  }

  render() {
    let {withdraw={},user={}} = this.state;
    let {userBaseInfo={},accountCapitalInfo={}} = user;
    return (
        <div>
            <NavBar navs={[
              {title:'提现列表',href:'/user/withdraw/list'},
              {title:'提现详情'}
            ]} />
            <ContentBody className='container'> 
                <Card title="用户基本信息" >
                    <div className='block-detail-container'>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>用户昵称</label>
                                <div>{userBaseInfo.nickname||'--'}</div>
                            </div>
                            <div className='d-col'>
                                <label>手机号</label>
                                <div>{userBaseInfo.phone||'--'}</div>
                            </div>
                        </div>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>账户余额</label>
                                <div>{accountCapitalInfo.accountBalance||'0'}元</div>
                            </div>
                            <div className='d-col'>
                                <label>可用余额</label>
                                <div>{accountCapitalInfo.availableBalance||'0'}元</div>
                            </div>
                        </div>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>冻结资金</label>
                                <div>{accountCapitalInfo.frozenCapital||'0'}元</div>
                            </div>
                        </div>
                    </div>
                </Card>
                <div className='height20'></div>
                <Card title="提现信息" >
                    <div className='block-detail-container'>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>真实姓名</label>
                                <div>{withdraw.real_name||"--"}</div>
                            </div>
                            <div className='d-col'>
                                <label>身份证号码</label>
                                <div>{withdraw.cash_acc_idcard||"--"}</div>
                            </div>
                        </div>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>银行卡号</label>
                                <div>{withdraw.cash_bank_acc_no||"--"}</div>
                            </div>
                            <div className='d-col'>
                                <label>预留手机号</label>
                                <div>{withdraw.cash_acc_tel||"--"}</div>
                            </div>
                        </div>
                        <div className='d-row'>
                            <div className='d-col'>
                                <label>所属银行</label>
                                <div>{withdraw.cash_bank_name||"--"}</div>
                            </div>
                            <div className='d-col'>
                                <label>提现金额</label>
                                <div>{withdraw.cash_amount||"0"}元</div>
                            </div>
                        </div>
                    </div>
                </Card>
            </ContentBody>
        </div>
    )
  }
}
WithdrawDetail.contextTypes= { router: React.PropTypes.object.isRequired};

